package com.beici.waterghost.service.classBoxInterface;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.beici.waterghost.mapper.classboxAlbumMapper;
import com.beici.waterghost.mapper.classboxNodeMapper;
import com.beici.waterghost.model.classBox.classboxAlbum;
import com.beici.waterghost.model.classBox.classboxNode;
import com.beici.waterghost.model.idRandom;
import com.beici.waterghost.model.resultes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @auther WaterGhost
 * @date 2022/3/22 19:40
 */
@Service
public class classBoxNodeService {

    @Autowired
    private classboxNodeMapper classboxNodeServer;

    // 查出指定区块的帖子
    public resultes getAlbumNodes(Long abId){
        List<classboxNode> nodes = classboxNodeServer.selectAllByAlbumId(abId);
        // 查询出用户
        return resultes.success(null,nodes);
    }

    // 查出指定帖子的详情信息
    public resultes getNodeDetails(Long cbId){
        // 查出文章
        classboxNode node = classboxNodeServer.selectNodeBycbId(cbId);
        if (node==null) {
            return resultes.Null();
        }
        // 查出评论
        return resultes.success(null,node);

    }

    public resultes addNode(classboxNode classboxNode){
        long longRandom = idRandom.getLongRandom();
        classboxNode.setCbId(longRandom);
        classboxNode.setCbDate(new Date());
        int insert = classboxNodeServer.insert(classboxNode);
        return resultes.success("发布成功",longRandom);
    }

}
